﻿using System.Windows;
using System.Windows.Controls;
using System;

namespace SecurePO
{
    /// <summary>
    /// Interaction logic for BioScanDialog.xaml
    /// </summary>
    public partial class BioScanDialog : UserControl
    {
        private static BioScanDialog m_instance;

        public BioScanDialog()
        {
            InitializeComponent();
        }

        internal static void Show<T>(T parent) where T : Grid
        {
            if (m_instance == null)
            {
                m_instance = new BioScanDialog();
            }
            m_instance.CancelButton.Click += CancelButton_Click;
            m_instance.Width = parent.Width;
            m_instance.Height = parent.Height;
            m_instance.HorizontalAlignment = HorizontalAlignment.Stretch;
            m_instance.VerticalAlignment = VerticalAlignment.Stretch;
            parent.Children.Insert(parent.Children.Count, m_instance);
        }

        private static void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }

        internal static void Close()
        {
            ((Grid)m_instance.Parent).Children.Remove(m_instance);
            m_instance = null;
        }
    }
}